//
//  BRMInfoMidView.m
//  BrezzeSaaS
//
//  Created by macos on 16.3.22.
//  Copyright © 2022 Brezze GWG. All rights reserved.
//

#import "BRMInfoMidView.h"
#import "BRMInfoListView.h"

@interface BRMInfoMidView ()
{
    BRMInfoListView *_idView;
    BRMInfoListView *_statusView;
    BRMInfoListView *_profitView;
}

@end

@implementation BRMInfoMidView

- (instancetype)init
{
    self = [super init];
    if (self) {
        [self setUI];
    }
    return self;
}

- (void)setIdStr:(NSString *)idStr {
    _idView.textView.text = idStr;
}

- (NSString *)idStr {
    return _idView.textView.text;
}

- (void)setStatusStr:(NSString *)statusStr {
    _statusView.textView.text = statusStr;
}

- (NSString *)statusStr {
    return _statusView.textView.text;
}

- (void)setProfitStr:(NSString *)profitStr {
    
//    self.isPutIn = YES;
    _profitStr = profitStr;
    _profitView.textView.text = profitStr;
}

- (void)setState:(NSInteger)state {
    _state = state;
    self.statusStr = [self statusBy:state];
    _statusView.textView.textColor = [self colorByState:state];
}

- (NSString *)statusBy:(NSInteger)state {
    //网点状态：0-待激活 1-正常 2-停止合作
    /*
     "shop_inOperation"="In operation";
     "shop_terminated"="Terminated";
     "shop_pendActvate"="Pending actvate";
     */
    if (state == 0) {
        return Localized(@"shop_pendActvate");
    }
    if (state == 1) {
        return Localized(@"shop_inOperation");
    }
    return Localized(@"shop_terminated");
}

- (UIColor *)colorByState:(NSInteger)state {
    
    if (state == 0) {
        return UIColorMake(255, 143, 0);
    }
    if (state == 2) {
        return UIColorMake(235, 35, 0);
    }
    
    return UIColorMake(30, 229, 146);
}

#pragma mark - UI --
- (void)setUI {
    
    self.layer.cornerRadius = 13;
    self.layer.masksToBounds = YES;
    self.backgroundColor = UIColorWhite;
    
    BRMInfoListView *idView = [[BRMInfoListView alloc] init];
    idView.titleStr = Localized(@"shop_merchantID");
    idView.textView.userInteractionEnabled = NO;
    idView.textView.textColor = kColorTitle;
    idView.titleStrColor = kColorTitle;
    [self addSubview:idView];
    
    
    BRMInfoListView *statusView = [[BRMInfoListView alloc] init];
    statusView.lineHidde = YES;
    [statusView.textView setEditable:NO];
    statusView.titleStr = Localized(@"shop_status");
    statusView.titleStrColor = kColorTitle;
    statusView.textView.textColor = kColorTitle;
    [self addSubview:statusView];
    _idView = idView;
    _statusView = statusView;
    [idView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.offset(46);
        make.left.right.offset(0);
    }];
    
    [statusView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.left.right.offset(0);
        make.top.equalTo(idView.mas_bottom);
    }];
   
    QMUILabel *titleL = [BRToolsView br_label:Localized(@"shop_baseInfo") textColor:UIColor.qd_titleTextColor font:[UIFont fontS:17]];
    [self addSubview:titleL];
    [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.offset(16);
        make.top.offset(16);
        make.height.mas_greaterThanOrEqualTo(20);
    }];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
